param(
    $testDir = ".\ModuleParts",
    
    # Other params that need to be splatted onto child scripts
    $module,
    $buildConfig,
    [switch]$break
)

$testDir = join-path (split-path $myInvocation.MyCommand.Path) $testDir

# Create a parameters dictionary for splatting onto chained scripts
$scriptParams = @{}
$scriptParams['module'] = $module;
$scriptParams['buildConfig'] = $buildConfig;
$scriptParams['break'] = $break;

# (Execute any script ending in .Tests.ps1 in the ModuleParts folder)
$tests = Get-ChildItem -Path $testDir -Filter *.Tests.ps1 -Recurse
$stopwatch = [system.diagnostics.stopwatch]::startnew();
foreach($test in $tests){
    write-host "Test $($test.Name)" -ForegroundColor:yellow;
    pushd (split-path $test.FullName)
    try{
        & $test.FullName @scriptParams;
        write-host "Pass $($test.Name) [$($stopwatch.Elapsed)]" -ForegroundColor:green;
        write-host
    }
    finally{
        popd;
    }
    $stopwatch.Reset();
    $stopwatch.Start();
}